package com.finace.money.ui.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.finace.money.R;
import com.finace.money.common.util.UIUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by zhangpeng on 2017/11/23.
 */

public class HomeMoneyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
    @Override
    public int getItemViewType(int position) {
        return super.getItemViewType(position);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new HomeMoneyViewHolder(LayoutInflater.from(UIUtil.getContext()).inflate(
                R.layout.item_home_all_money, parent, false));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

        if(holder instanceof HomeMoneyViewHolder){
            HomeMoneyViewHolder homeMoneyViewHolder = (HomeMoneyViewHolder) holder;
            homeMoneyViewHolder.tvNumber.setText(String.valueOf(position+1));
            switch (position){
                case 0:
                    homeMoneyViewHolder.tvNumber.setBackgroundResource(R.drawable.icon_number_one);
                    homeMoneyViewHolder.tvMoney.setText("231123123.00元");
                    break;
                case 1:
                    homeMoneyViewHolder.tvNumber.setBackgroundResource(R.drawable.icon_number_two);
                    homeMoneyViewHolder.tvMoney.setText("23112312.00元");
                    break;
                case 2:
                    homeMoneyViewHolder.tvNumber.setBackgroundResource(R.drawable.icon_number_three);
                    homeMoneyViewHolder.tvMoney.setText("2311231.00元");
                    break;
                case 3:
                    homeMoneyViewHolder.tvNumber.setBackgroundResource(R.drawable.icon_number_four);
                    homeMoneyViewHolder.tvMoney.setText("23112.00元");
                    break;
                case 4:
                    homeMoneyViewHolder.tvNumber.setBackgroundResource(R.drawable.icon_number_four);
                    homeMoneyViewHolder.tvMoney.setText("7123.00元");
                    break;
                case 5:
                    homeMoneyViewHolder.tvNumber.setBackgroundResource(R.drawable.icon_number_four);
                    homeMoneyViewHolder.tvMoney.setText("5876.00元");
                    break;
                case 6:
                    homeMoneyViewHolder.tvNumber.setBackgroundResource(R.drawable.icon_number_four);
                    homeMoneyViewHolder.tvMoney.setText("623.00元");
                    break;
                case 7:
                    homeMoneyViewHolder.tvNumber.setBackgroundResource(R.drawable.icon_number_four);
                    homeMoneyViewHolder.tvMoney.setText("23.00元");
                    break;
                case 8:
                    homeMoneyViewHolder.tvNumber.setBackgroundResource(R.drawable.icon_number_four);
                    homeMoneyViewHolder.tvMoney.setText("10.00元");
                    break;
            }
        }
    }

    @Override
    public int getItemCount() {
        return 9;
    }

    public class HomeMoneyViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.tv_number)
        TextView tvNumber;
        @BindView(R.id.tv_phone)
        TextView tvPhone;
        @BindView(R.id.tv_money)
        TextView tvMoney;
        public HomeMoneyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
